package com.easybuilder.blog.controller;

import com.easybuilder.blog.entity.BlogReply;
import com.easybuilder.blog.service.ReplyService;
import com.easybuilder.common.base.controller.BaseController;
import com.easybuilder.common.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/reply")
public class ReplyController extends BaseController {

    @Autowired
    private ReplyService replyService;

    @PostMapping("/publish")
    public Object publish(@RequestBody BlogReply reply) {
        if (reply == null || StringUtil.isEmpty(reply.getContent())) {
            return Error("服务异常");
        }
        replyService.publish(reply);
        return OK(reply);
    }
}
